<template>
  <div class="app-container">
    <div class="hor pd-b10 ver-center">
      <div>{{ this.projectInfo.province + "-" + this.projectInfo.city + "-" + this.projectInfo.name }}</div>
      <div class="pd-l-10">高低压工程统计</div>
    </div>
    <div class="hor mg-b-10">
      <div class="match-width">
        <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
          <el-tab-pane label="到定标" name="1">
            <div class="flex1 pd-tb10">
              <div class="hor">
                <el-button size="mini" @click.native="openTable(1)" v-if="conditionType == 2">展开</el-button>
                <el-button size="mini" @click.native="openTable(2)" v-if="conditionType == 1">折叠</el-button>
                <div class="flex1"></div>
                <el-button type="primary" slot="reference" :loading="onSaveLoading" class=" mg-l-10"
                           @click="onClickAddProjectData()">添加对比项目
                </el-button>
                <el-button type="primary" slot="reference" :loading="onSaveLoading" class=" mg-l-10"
                           @click="onClickDingBiaoData()">生成定标阶段数据沉淀
                </el-button>
                <el-button type="primary" slot="reference" :loading="onSaveLoading" class=" mg-l-10"
                           @click="onClickExportDb()">导出
                </el-button>
              </div>
            </div>
            <div>
              <div class="match-width">
                <el-tabs v-model="activeNameCompany" @tab-click="handleClickCompany">
                  <el-tab-pane
                    v-for="(tab, index) in allList"
                    :key="index"
                    :label="tab.supplyCompany.name"
                    :name="tab.count"
                  >
                    <el-table
                      :data="tab.dataChenDian"
                      stripe
                      border
                      style="width: 100%">
<!--                      <el-table-column label="分类" align="center" width="180">-->
<!--                        <template slot-scope="scope">-->
<!--                          {{ scope.row.fenXiTypeName }}-->
<!--                        </template>-->
<!--                      </el-table-column>-->
                      <el-table-column label="分类" align="center" width="180">
                        <template slot-scope="scope">
                          <div :style="{'background-color': getBackgroundColor(scope.row.fenXiType)}">
                            {{ scope.row.fenXiTypeName }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="标底A" align="center" width="">
                        <el-table-column label="标底价(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.basePriceA }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.basePriceA" placeholder="请输入"
                                        @change="onInputChangeBd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.basePriceAjm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.basePriceAgj" placeholder="请输入"
                                      @change="onInputChangeBd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="拟定标B" align="center" width="">
                        <el-table-column label="定标价(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.dingBiaoPriceB }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.dingBiaoPriceB" placeholder="请输入"
                                        @change="onInputChangeBd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.dingBiaoPriceBjm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.dingBiaoPriceBgj" placeholder="请输入"
                                      @change="onInputChangeBd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="同城市历史项目数据C" align="center" width="">
                        <el-table-column label="实施方案（审核价）(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.choiceBasePriceC }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.choiceBasePriceC" placeholder="请输入"
                                        @change="onInputChangeBd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.choiceBasePriceCjm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.choiceBasePriceCgj" placeholder="请输入"
                                      @change="onInputChangeBd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="拟定标-标底差异 B-A" align="center" width="">
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.baPriceJm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="差异原因分析" align="center" width="">
                          <template slot-scope="scope">
                            <el-input type="textarea" maxlength="1024" :autosize="{minRows: 3, maxRows: 5}" placeholder="请输入"
                                      v-model="scope.row.baPriceCysm" @change="onInputChangeBd(scope.row)">
                            </el-input>
<!--                            <el-input v-model="scope.row.baPriceCysm" placeholder="请输入"-->
<!--                                      @change="onInputChangeBd(scope.row)"/>-->
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="拟定标-同城市历史项目差异 B-C" align="center" width="">
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.bcPriceJm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="差异原因分析" align="center" width="">
                          <template slot-scope="scope">
                            <el-input type="textarea" maxlength="1024" :autosize="{minRows: 3, maxRows: 5}" placeholder="请输入"
                                      v-model="scope.row.bcPriceCysm" @change="onInputChangeBd(scope.row)">
                            </el-input>
<!--                            <el-input v-model="scope.row.bcPriceCysm" placeholder="请输入"-->
<!--                                      @change="onInputChangeBd(scope.row)"/>-->
                          </template>
                        </el-table-column>
                      </el-table-column>
                    </el-table>
                  </el-tab-pane>
                </el-tabs>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="到实施定标" name="2">
            <div class="hor pd-tb10">
              <el-button size="mini" @click.native="openTable(1)" v-if="conditionType == 2">展开</el-button>
              <el-button size="mini" @click.native="openTable(2)" v-if="conditionType == 1">折叠</el-button>
              <div class="flex1"></div>
              <el-button type="primary" slot="reference" :loading="onSaveLoading" class=" mg-l-10"
                         @click="onClickSsDingBiaoData()">生成实施定标阶段数据沉淀
              </el-button>
              <el-button type="primary" slot="reference" :loading="onSaveLoading" class=" mg-l-10"
                         @click="onClickExportSsdb()">导出
              </el-button>
            </div>
            <div>
              <div class="match-width">
                <el-tabs v-model="activeNameCompany" @tab-click="handleClickCompany">
                  <el-tab-pane
                    v-for="(tab, index) in allList"
                    :key="index"
                    :label="tab.supplyCompany.name"
                    :name="tab.count"
                  >
                    <el-table
                      :data="tab.dataChenDian"
                      stripe
                      border
                      style="width: 100%">
<!--                      <el-table-column label="分类" align="center" width="180">-->
<!--                        <template slot-scope="scope">-->
<!--                          {{ scope.row.fenXiTypeName }}-->
<!--                        </template>-->
<!--                      </el-table-column>-->
                      <el-table-column label="分类" align="center" width="180">
                        <template slot-scope="scope">
                          <div :style="{'background-color': getBackgroundColor(scope.row.fenXiType)}">
                            {{ scope.row.fenXiTypeName }}
                          </div>
                        </template>
                      </el-table-column>
                      <el-table-column label="标底A" align="center" width="">
                        <el-table-column label="标底价(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.basePriceA }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.basePriceA" placeholder="请输入"
                                        @change="onInputChangeSsbd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <!--                <el-table-column label="标底价调整(元)" align="center" width="">-->
                        <!--                  <template slot-scope="scope">-->
                        <!--                    {{ scope.row.basePriceAtz }}-->
                        <!--                  </template>-->
                        <!--                </el-table-column>-->
                        <!--                <el-table-column label="标底调整差异(万元)" align="center" width="">-->
                        <!--                  <template slot-scope="scope">-->
                        <!--                    {{ scope.row.basePriceAtzcy }}-->
                        <!--                  </template>-->
                        <!--                </el-table-column>-->
                        <el-table-column label="差异说明" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.basePriceAcysm" placeholder="请输入"
                                      @change="onInputChangeSsbd(scope.row)"/>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.basePriceAjm }}
                          </template>
                        </el-table-column>
                        <!--                <el-table-column label="调整标底价建面单方(元/㎡)" align="center" width="">-->
                        <!--                  <template slot-scope="scope">-->
                        <!--                    {{ scope.row.basePriceAtzjm }}-->
                        <!--                  </template>-->
                        <!--                </el-table-column>-->
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.basePriceAgj" placeholder="请输入"
                                      @change="onInputChangeSsbd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="拟定标B" align="center" width="">
                        <el-table-column label="定标价(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.dingBiaoPriceB }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.dingBiaoPriceB" placeholder="请输入"
                                        @change="onInputChangeSsbd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.dingBiaoPriceBjm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.dingBiaoPriceBgj" placeholder="请输入"
                                      @change="onInputChangeSsbd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="落地实施方案（标底价）C" align="center" width="">
                        <el-table-column label="实施方案（审核价）(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.ssBasePriceC }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.ssBasePriceC" placeholder="请输入"
                                        @change="onInputChangeSsbd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.ssBasePriceCjm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.ssBasePriceCgj" placeholder="请输入"
                                      @change="onInputChangeSsbd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="落地实施方案（单位最终价）D" align="center" width="">
                        <el-table-column label="实施方案（审核价）(元)" align="center" width="">
                          <template slot-scope="scope">
                            <div v-if="scope.row.fenXiType != 3">
                              {{ scope.row.ssDingBiaoPriceD }}
                            </div>
                            <div v-if="scope.row.fenXiType == 3">
                              <el-input v-model="scope.row.ssDingBiaoPriceD" placeholder="请输入"
                                        @change="onInputChangeSsbd(scope.row)"/>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.ssDingBiaoPriceDjm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="关键单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.ssDingBiaoPriceDgj" placeholder="请输入"
                                      @change="onInputChangeSsbd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="实施方案标底-标底（方案差异） C-A" align="center" width="">
                        <el-table-column label="金额(万元)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.caPrice }}
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.caPriceJm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="差异说明" align="center" width="">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.caPriceCysm" placeholder="请输入"
                                      @change="onInputChangeSsbd(scope.row)"/>
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="实施方案单位报价-实施方案标底（商务差异）D-C" align="center" width="">
                        <el-table-column label="金额(万元)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.dcPrice }}
                          </template>
                        </el-table-column>
                        <el-table-column label="建面单方(元/㎡)" align="center" width="">
                          <template slot-scope="scope">
                            {{ scope.row.dcPriceJm }}
                          </template>
                        </el-table-column>
                        <el-table-column label="差异原因分析" align="center" width="">
                          <template slot-scope="scope">
                            <el-input type="textarea" maxlength="1024" :autosize="{minRows: 3, maxRows: 5}" placeholder="请输入"
                                      v-model="scope.row.dcPriceCysm" @change="onInputChangeSsbd(scope.row)">
                            </el-input>
<!--                            <el-input v-model="scope.row.dcPriceCysm" placeholder="请输入"-->
<!--                                      @change="onInputChangeSsbd(scope.row)"/>-->
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="备注" align="center" width="">
                        <template slot-scope="scope">
                          <el-input type="textarea" maxlength="1024" :autosize="{minRows: 3, maxRows: 5}" placeholder="请输入"
                                    v-model="scope.row.remarks" @change="onInputChangeSsbd(scope.row)">
                          </el-input>
<!--                          <el-input v-model="scope.row.remarks" placeholder="请输入"-->
<!--                                    @change="onInputChangeSsbd(scope.row)"/>-->
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-tab-pane>
                </el-tabs>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <div>
      <el-dialog
        title="选择要对比的项目和公司"
        :visible.sync="addProjectDialogVisible"
        width="85%"
        :before-close="handleClose">
        <div class="flex1 pd-tb10">
          <div class="hor pd-tb5">
            <div class="hor pd-l-10">
              <el-input class="" v-model="choiceProvince" placeholder="请输入省份" clearable></el-input>
            </div>
            <div class="hor pd-l-10">
              <el-input class="" v-model="choiceCity" placeholder="请输入城市" clearable></el-input>
            </div>
            <div class="pd-l-10"></div>
            <el-button type="primary" icon="el-icon-search" @click="onClickSearch()" class="">筛选
            </el-button>
            <div class="flex1"></div>
          </div>
          <div>
            <el-table
              ref="table"
              v-loading="listLoading"
              :data="contrastProjectList"
              :height="400"
              element-loading-text="Loading"
              @cell-click="onCellClick"
              @row-click="onItemClick"
              @row-dblclick="onItemDoubleClick"
              border
              fit
              highlight-current-row
            >
              <el-table-column
                fixed
                label=""
                width="55">
                <template slot-scope="scope">
                  <el-radio v-model="selectedRow" :label="scope.row" @change="handleRadioChange">&nbsp;</el-radio>
                </template>
              </el-table-column>
              <el-table-column label="地区" align="center" width="">
                <template slot-scope="scope">
                  {{ scope.row.project.province != null ? scope.row.project.province : "" }}/
                  {{ scope.row.project.city != null ? scope.row.project.city : "" }}
                </template>
              </el-table-column>
              <el-table-column label="项目名称" align="center" width="">
                <template slot-scope="scope">
                  {{ scope.row.project.name }}
                </template>
              </el-table-column>
              <el-table-column label="公司" align="center" width="">
                <template slot-scope="scope">
                  {{ scope.row.supplyCompany.name }}
                </template>
              </el-table-column>
              <el-table-column label="创建时间" width="300" align="center">
                <template slot-scope="scope">
                  {{ scope.row.biddingCompany.createTime }}
                </template>
              </el-table-column>
            </el-table>
          </div>
          <span slot="footer" class="dialog-footer  hor hor-center">
             <el-button @click="addProjectDialogVisible = false">取 消</el-button>
            <el-button type="primary" :loading="onSaveLoading"
                       @click="saveProjectData">添加</el-button>
        </span>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import {getCityData} from "@/js/cityData";

const request = require('@/api/comprehensive/statisticalAnalysis')
const requestDb = require('@/api/comprehensive/precipitateDb')
const requestSsdb = require('@/api/comprehensive/precipitateSsdb')
export default {

  data() {
    return {
      activeName: "1",
      projectInfo: {},
      allList: [],
      page: 1,
      size: 20,
      total: 0,
      autoHeight: 600,//根据屏幕高度自动计算的高度
      //筛选参数
      params: {
        flag: 1,
      },
      listLoading: false,
      onSaveLoading: false,
      areaData: [],
      addProjectDialogVisible: false,
      contrastProjectList: [],
      selectedRow: null,
      choiceProvince: null,
      choiceCity: null,
      choiceProjectId: null,
      choiceSupplyCompanyId: null,
      activeNameCompany: 1,
      conditionType:1,
    }
  },
  beforeMount() {
    this.autoHeight = document.body.scrollHeight - 220
    this.projectInfo = JSON.parse(this.$route.query.projectInfo)
  },
  mounted() {
    this.areaData = getCityData()
    this.getChoiceProject()
    this.handleClick()
    //去掉第三级的信息
    for (let i = 0; i < this.areaData.length; i++) {
      if (this.areaData[i].children != null && this.areaData[i].children.length > 0) {
        for (let j = 0; j < this.areaData[i].children.length; j++) {
          this.areaData[i].children[j].children = null
        }
      }
    }
  },
  methods: {
    formatDate(timestamp) {
      const date = new Date(timestamp);
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0');
      const day = String(date.getDate()).padStart(2, '0');
      const hours = String(date.getHours()).padStart(2, '0');
      const minutes = String(date.getMinutes()).padStart(2, '0');
      const seconds = String(date.getSeconds()).padStart(2, '0');

      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    getJieDuanName(value) {
      switch (value) {
        case 1:
          return "标底";
        case 2:
          return "回标1";
        case 3:
          return "回标2";
        case 4:
          return "回标3";
        case 5:
          return "回标4"
        case 6:
          return "定标"
        case 7:
          return "实施标底"
        case 8:
          return "实施定标"
        default:
          return "";
      }
    },
    getSsdbData() {
      this.listLoading = true
      const data = new FormData()
      data.append('projectId', this.projectInfo.id)
      data.append('conditionType', this.conditionType)
      const sortList = []
      sortList.push(
        {
          direction: 'asc',
          property: 'fenXiType'
        }
      )
      data.append('sortJsonStr', JSON.stringify(sortList))
      requestSsdb.getSsdbList(data).then(response => {
        this.allList = response.data
        this.total = response.totalElements
        this.listLoading = false
      })
    },
    getDbData() {
      this.listLoading = true
      const data = new FormData()
      data.append('projectId', this.projectInfo.id)
      data.append('conditionType', this.conditionType)
      const sortList = []
      sortList.push(
        {
          direction: 'asc',
          property: 'fenXiType'
        }
      )
      data.append('sortJsonStr', JSON.stringify(sortList))
      requestDb.getDbList(data).then(response => {
        this.allList = response.data
        this.total = response.totalElements
        this.listLoading = false
      })
    },

    getChoiceProject() {
      this.listLoading = true
      const data = new FormData()
      data.append('projectId', this.projectInfo.id);
      if (this.choiceProvince != null) {
        data.append('province', this.choiceProvince);
      }
      if (this.choiceCity != null) {
        data.append('city', this.choiceCity);
      }
      const sortList = []
      sortList.push(
        {
          direction: 'desc',
          property: 'createTime'
        }
      )
      data.append('sortJsonStr', JSON.stringify(sortList))
      request.getChoiceProject(data).then(response => {
        this.contrastProjectList = response.data
        this.total = response.totalElements
        this.listLoading = false
      })
    },

    handleClick() {
      if (this.activeName == "1") {
        this.getDbData()
      } else if (this.activeName == "2") {
        this.getSsdbData()
      }
    },
    handleClickCompany(tab, event) {
      console.log(tab, event);
    },
    handleClose() {
      this.addProjectDialogVisible = false;
      this.getChoiceProject()
    },
    onCellClick(row, column, cell, event) {
      // if (column.type == 'selection') {
      //   this.$refs.table.toggleRowSelection(row)
      // }
    },
    onClickAddProjectData() {
      this.addProjectDialogVisible = true
      this.getChoiceProject()
    },
    onItemClick(row) {//单行点击
      // 单选模式下，点击行应该切换选中状态
      this.$refs.table.toggleRowSelection(row);
    },
    handleRadioChange(row) {
      this.selectedRow = row;
    },
    onItemDoubleClick(row) {//单行双击
      this.onClickView(row)
    },
    onClickSearch() {
      this.page = 1;
      if (!this.isEmpty(this.name)) {
        this.params['province_like'] = ('%' + this.choiceProvince.trim() + '%')
      } else {
        this.params['province_like'] = ''
      }
      if (!this.isEmpty(this.modelCode)) {
        this.params['city_like'] = ('%' + this.choiceCity.trim() + '%')
      } else {
        this.params['city_like'] = ''
      }
      this.getChoiceProject()
    },
    onClickDingBiaoData() {
      this.onSaveLoading = true
      const data = new FormData()
      data.append('projectId', this.projectInfo.id);
      if (this.choiceProjectId != null) {
        data.append('choiceProjectId', this.choiceProjectId);
      }
      if (this.choiceSupplyCompanyId != null) {
        data.append('choiceSupplyCompanyId', this.choiceSupplyCompanyId);
      }
      request.generatePrecipitate(data).then(response => {
        this.onSaveLoading = false
        this.$message({
          message: '保存成功',
          type: 'success',
          duration: 2000
        })
        this.getDbData()
        this.choiceProjectId = null
        this.choiceSupplyCompanyId = null
      }).catch((e) => {
        this.onSaveLoading = false
      })
    },
    onClickSsDingBiaoData() {
      this.onSaveLoading = true
      const data = new FormData()
      data.append('projectId', this.projectInfo.id);
      request.generatePrecipitateSsdb(data).then(response => {
        this.onSaveLoading = false
        this.$message({
          message: '保存成功',
          type: 'success',
          duration: 2000
        })
        this.getSsdbData()
      }).catch((e) => {
        this.onSaveLoading = false
      })
    },
    saveProjectData() {
      this.onSaveLoading = true;
      this.choiceProjectId = this.selectedRow.project.id
      this.choiceSupplyCompanyId = this.selectedRow.supplyCompany.id
      this.onClickDingBiaoData()
      this.onSaveLoading = false;
      this.addProjectDialogVisible = false
    },

    onInputChangeBd(row) {
      this.onSaveLoading = true
      //把选择的权限赋值过去
      const data = new FormData()
      data.append('json', JSON.stringify(row));
      requestDb.saveByJson(data).then(response => {
        this.onSaveLoading = false
        this.infoDialogShow = false
        this.$message({
          message: '保存成功',
          type: 'success',
          duration: 2000
        })
        this.getDbData()
      }).catch((e) => {
        this.onSaveLoading = false
      })
    },
    onInputChangeSsbd(row) {
      this.onSaveLoading = true
      //把选择的权限赋值过去
      const data = new FormData()
      data.append('json', JSON.stringify(row));
      requestSsdb.saveByJson(data).then(response => {
        this.onSaveLoading = false
        this.infoDialogShow = false
        this.$message({
          message: '保存成功',
          type: 'success',
          duration: 2000
        })
        this.getSsdbData()
      }).catch((e) => {
        this.onSaveLoading = false
      })
    },
    onClickExportDb() {
      window.open(process.env.VUE_APP_BASE_API + "/mgt/precipitateDb/exportDb?projectId=" + this.projectInfo.id)
    },
    onClickExportSsdb() {
      window.open(process.env.VUE_APP_BASE_API + "/mgt/precipitateSsdb/exportSsdb?projectId=" + this.projectInfo.id)
    },
    openTable(type){
      this.conditionType = type
      if (this.activeName == "1") {
        this.getDbData()
      } else if (this.activeName == "2") {
        this.getSsdbData()
      }
    },
    getBackgroundColor(fenXiType) {
      const specialTypes = [1, 2, 3, 4, 9, 14, 19, 24, 29, 30, 31, 32, 33, 34, 35];
      // 检查fenXiType是否包含在specialTypes数组中
      if (specialTypes.includes(fenXiType)) {
        return '#fdb02a'; // 如果是，返回指定的背景色
      }
      return ''; // 否则不设置背景色
    }
  }
}
</script>

<style scoped>

</style>
